
########################################################################################################################
# Replication Materials for "Policy over Protest: Experimental Evidence on the Drivers of Support for Movement Parties"
########################################################################################################################


#### Set working directory
setwd("SET_YOUR_PATH/")

#### Load packages

library(tidyverse)
library(haven)
library(cregg)

write.excel <- function(x,row.names=FALSE,col.names=TRUE,...) {
  write.table(x,"clipboard",sep="\t",row.names=row.names,col.names=col.names,...)
}

#### Load datasets
HUcj <- read_sav("SET_YOUR_PATH/Hungary_PoP.sav")
DKcj <- read_sav("SET_YOUR_PATH/Denmark_PoP.sav")
UKcj <- read_sav("SET_YOUR_PATH/UK_PoP.sav")
ITcj <- read_sav("SET_YOUR_PATH/Italy_PoP.sav")
ROcj <- read_sav("SET_YOUR_PATH/Romania_PoP.sav")
DEcj <- read_sav("SET_YOUR_PATH/Germany_PoP.sav")

# Merge in one dataframe
CJ <- bind_rows(DEcj, DKcj, HUcj, ITcj, ROcj, UKcj)
colnames(CJ)


# Create one dataframe per conjoint screen and synchronize column names

df1 <- subset(CJ, select= -c(src_2_attribut1_1, src_2_attribut1_2, src_2_attribut2_1, 
                             src_2_attribut2_2, src_2_attribut3_1, src_2_attribut3_2,
                             src_2_attribut4_1, src_2_attribut4_2, src_2_attribut5_1,
                             src_2_attribut5_2, src_3_attribut1_1, src_3_attribut1_2, 
                             src_3_attribut2_1, src_3_attribut2_2, src_3_attribut3_1, 
                             src_3_attribut3_2, src_3_attribut4_1, src_3_attribut4_2, 
                             src_3_attribut5_1, src_3_attribut5_2, src_4_attribut1_1, 
                             src_4_attribut1_2, src_4_attribut2_1, src_4_attribut2_2, 
                             src_4_attribut3_1, src_4_attribut3_2, src_4_attribut4_1, 
                             src_4_attribut4_2, src_4_attribut5_1, src_4_attribut5_2,
                             src_5_attribut1_1, src_5_attribut1_2, src_5_attribut2_1, 
                             src_5_attribut2_2, src_5_attribut3_1, src_5_attribut3_2,
                             src_5_attribut4_1, src_5_attribut4_2, src_5_attribut5_1,
                             src_5_attribut5_2, cjchoice_2, cjrating_2_1, cjrating_2_2, 
                             cjchoice_3, cjrating_3_1, cjrating_3_2, cjchoice_4, 
                             cjrating_4_1,cjrating_4_2, cjchoice_5, cjrating_5_1, cjrating_5_2))
colnames(df1)

df1$Scr_Conjoint = 1
colnames(df1)[which(names(df1) == "src_1_attribut1_1")] <- "attribut1_1"
colnames(df1)[which(names(df1) == "src_1_attribut1_2")] <- "attribut1_2"
colnames(df1)[which(names(df1) == "src_1_attribut2_1")] <- "attribut2_1"
colnames(df1)[which(names(df1) == "src_1_attribut2_2")] <- "attribut2_2"
colnames(df1)[which(names(df1) == "src_1_attribut3_1")] <- "attribut3_1"
colnames(df1)[which(names(df1) == "src_1_attribut3_2")] <- "attribut3_2"
colnames(df1)[which(names(df1) == "src_1_attribut4_1")] <- "attribut4_1"
colnames(df1)[which(names(df1) == "src_1_attribut4_2")] <- "attribut4_2"
colnames(df1)[which(names(df1) == "src_1_attribut5_1")] <- "attribut5_1"
colnames(df1)[which(names(df1) == "src_1_attribut5_2")] <- "attribut5_2"
colnames(df1)[which(names(df1) == "cjrating_1_1")] <- "C1_rating"
colnames(df1)[which(names(df1) == "cjrating_1_2")] <- "C2_rating"
colnames(df1)[which(names(df1) == "cjchoice_1")] <- "CJ_Choice"
colnames(df1)



df2 <- subset(CJ, select= -c(src_1_attribut1_1, src_1_attribut1_2, src_1_attribut2_1, 
                             src_1_attribut2_2, src_1_attribut3_1, src_1_attribut3_2,
                             src_1_attribut4_1, src_1_attribut4_2, src_1_attribut5_1,
                             src_1_attribut5_2, src_3_attribut1_1, src_3_attribut1_2, 
                             src_3_attribut2_1, src_3_attribut2_2, src_3_attribut3_1, 
                             src_3_attribut3_2, src_3_attribut4_1, src_3_attribut4_2, 
                             src_3_attribut5_1, src_3_attribut5_2, src_4_attribut1_1, 
                             src_4_attribut1_2, src_4_attribut2_1, src_4_attribut2_2, 
                             src_4_attribut3_1, src_4_attribut3_2, src_4_attribut4_1, 
                             src_4_attribut4_2, src_4_attribut5_1, src_4_attribut5_2,
                             src_5_attribut1_1, src_5_attribut1_2, src_5_attribut2_1, 
                             src_5_attribut2_2, src_5_attribut3_1, src_5_attribut3_2,
                             src_5_attribut4_1, src_5_attribut4_2, src_5_attribut5_1,
                             src_5_attribut5_2, cjchoice_1, cjrating_1_1, cjrating_1_2, 
                             cjchoice_3, cjrating_3_1, cjrating_3_2, cjchoice_4, 
                             cjrating_4_1,cjrating_4_2, cjchoice_5, cjrating_5_1, cjrating_5_2))
colnames(df2)

df2$Scr_Conjoint = 2
colnames(df2)[which(names(df2) == "src_2_attribut1_1")] <- "attribut1_1"
colnames(df2)[which(names(df2) == "src_2_attribut1_2")] <- "attribut1_2"
colnames(df2)[which(names(df2) == "src_2_attribut2_1")] <- "attribut2_1"
colnames(df2)[which(names(df2) == "src_2_attribut2_2")] <- "attribut2_2"
colnames(df2)[which(names(df2) == "src_2_attribut3_1")] <- "attribut3_1"
colnames(df2)[which(names(df2) == "src_2_attribut3_2")] <- "attribut3_2"
colnames(df2)[which(names(df2) == "src_2_attribut4_1")] <- "attribut4_1"
colnames(df2)[which(names(df2) == "src_2_attribut4_2")] <- "attribut4_2"
colnames(df2)[which(names(df2) == "src_2_attribut5_1")] <- "attribut5_1"
colnames(df2)[which(names(df2) == "src_2_attribut5_2")] <- "attribut5_2"
colnames(df2)[which(names(df2) == "cjrating_2_1")] <- "C1_rating"
colnames(df2)[which(names(df2) == "cjrating_2_2")] <- "C2_rating"
colnames(df2)[which(names(df2) == "cjchoice_2")] <- "CJ_Choice"
colnames(df2)

df3 <- subset(CJ, select= -c(src_2_attribut1_1, src_2_attribut1_2, src_2_attribut2_1, 
                             src_2_attribut2_2, src_2_attribut3_1, src_2_attribut3_2,
                             src_2_attribut4_1, src_2_attribut4_2, src_2_attribut5_1,
                             src_2_attribut5_2, src_1_attribut1_1, src_1_attribut1_2, 
                             src_1_attribut2_1, src_1_attribut2_2, src_1_attribut3_1, 
                             src_1_attribut3_2, src_1_attribut4_1, src_1_attribut4_2, 
                             src_1_attribut5_1, src_1_attribut5_2, src_4_attribut1_1, 
                             src_4_attribut1_2, src_4_attribut2_1, src_4_attribut2_2, 
                             src_4_attribut3_1, src_4_attribut3_2, src_4_attribut4_1, 
                             src_4_attribut4_2, src_4_attribut5_1, src_4_attribut5_2,
                             src_5_attribut1_1, src_5_attribut1_2, src_5_attribut2_1, 
                             src_5_attribut2_2, src_5_attribut3_1, src_5_attribut3_2,
                             src_5_attribut4_1, src_5_attribut4_2, src_5_attribut5_1,
                             src_5_attribut5_2, cjchoice_1, cjrating_1_1, cjrating_1_2, 
                             cjchoice_2, cjrating_2_1, cjrating_2_2, cjchoice_4, 
                             cjrating_4_1,cjrating_4_2, cjchoice_5, cjrating_5_1, cjrating_5_2))
colnames(df3)

df3$Scr_Conjoint = 3
colnames(df3)[which(names(df3) == "src_3_attribut1_1")] <- "attribut1_1"
colnames(df3)[which(names(df3) == "src_3_attribut1_2")] <- "attribut1_2"
colnames(df3)[which(names(df3) == "src_3_attribut2_1")] <- "attribut2_1"
colnames(df3)[which(names(df3) == "src_3_attribut2_2")] <- "attribut2_2"
colnames(df3)[which(names(df3) == "src_3_attribut3_1")] <- "attribut3_1"
colnames(df3)[which(names(df3) == "src_3_attribut3_2")] <- "attribut3_2"
colnames(df3)[which(names(df3) == "src_3_attribut4_1")] <- "attribut4_1"
colnames(df3)[which(names(df3) == "src_3_attribut4_2")] <- "attribut4_2"
colnames(df3)[which(names(df3) == "src_3_attribut5_1")] <- "attribut5_1"
colnames(df3)[which(names(df3) == "src_3_attribut5_2")] <- "attribut5_2"
colnames(df3)[which(names(df3) == "cjrating_3_1")] <- "C1_rating"
colnames(df3)[which(names(df3) == "cjrating_3_2")] <- "C2_rating"
colnames(df3)[which(names(df3) == "cjchoice_3")] <- "CJ_Choice"
colnames(df3)

df4 <- subset(CJ, select= -c(src_2_attribut1_1, src_2_attribut1_2, src_2_attribut2_1, 
                             src_2_attribut2_2, src_2_attribut3_1, src_2_attribut3_2,
                             src_2_attribut4_1, src_2_attribut4_2, src_2_attribut5_1,
                             src_2_attribut5_2, src_3_attribut1_1, src_3_attribut1_2, 
                             src_3_attribut2_1, src_3_attribut2_2, src_3_attribut3_1, 
                             src_3_attribut3_2, src_3_attribut4_1, src_3_attribut4_2, 
                             src_3_attribut5_1, src_3_attribut5_2, src_1_attribut1_1, 
                             src_1_attribut1_2, src_1_attribut2_1, src_1_attribut2_2, 
                             src_1_attribut3_1, src_1_attribut3_2, src_1_attribut4_1, 
                             src_1_attribut4_2, src_1_attribut5_1, src_1_attribut5_2,
                             src_5_attribut1_1, src_5_attribut1_2, src_5_attribut2_1, 
                             src_5_attribut2_2, src_5_attribut3_1, src_5_attribut3_2,
                             src_5_attribut4_1, src_5_attribut4_2, src_5_attribut5_1,
                             src_5_attribut5_2, cjchoice_1, cjrating_1_1, cjrating_1_2, 
                             cjchoice_2, cjrating_2_1, cjrating_2_2, cjchoice_3, 
                             cjrating_3_1, cjrating_3_2, cjchoice_5, cjrating_5_1, cjrating_5_2))
colnames(df4)

df4$Scr_Conjoint = 4
colnames(df4)[which(names(df4) == "src_4_attribut1_1")] <- "attribut1_1"
colnames(df4)[which(names(df4) == "src_4_attribut1_2")] <- "attribut1_2"
colnames(df4)[which(names(df4) == "src_4_attribut2_1")] <- "attribut2_1"
colnames(df4)[which(names(df4) == "src_4_attribut2_2")] <- "attribut2_2"
colnames(df4)[which(names(df4) == "src_4_attribut3_1")] <- "attribut3_1"
colnames(df4)[which(names(df4) == "src_4_attribut3_2")] <- "attribut3_2"
colnames(df4)[which(names(df4) == "src_4_attribut4_1")] <- "attribut4_1"
colnames(df4)[which(names(df4) == "src_4_attribut4_2")] <- "attribut4_2"
colnames(df4)[which(names(df4) == "src_4_attribut5_1")] <- "attribut5_1"
colnames(df4)[which(names(df4) == "src_4_attribut5_2")] <- "attribut5_2"
colnames(df4)[which(names(df4) == "cjrating_4_1")] <- "C1_rating"
colnames(df4)[which(names(df4) == "cjrating_4_2")] <- "C2_rating"
colnames(df4)[which(names(df4) == "cjchoice_4")] <- "CJ_Choice"
colnames(df4)

df5 <- subset(CJ, select= -c(src_2_attribut1_1, src_2_attribut1_2, src_2_attribut2_1, 
                             src_2_attribut2_2, src_2_attribut3_1, src_2_attribut3_2,
                             src_2_attribut4_1, src_2_attribut4_2, src_2_attribut5_1,
                             src_2_attribut5_2, src_3_attribut1_1, src_3_attribut1_2, 
                             src_3_attribut2_1, src_3_attribut2_2, src_3_attribut3_1, 
                             src_3_attribut3_2, src_3_attribut4_1, src_3_attribut4_2, 
                             src_3_attribut5_1, src_3_attribut5_2, src_4_attribut1_1, 
                             src_4_attribut1_2, src_4_attribut2_1, src_4_attribut2_2, 
                             src_4_attribut3_1, src_4_attribut3_2, src_4_attribut4_1, 
                             src_4_attribut4_2, src_4_attribut5_1, src_4_attribut5_2,
                             src_1_attribut1_1, src_1_attribut1_2, src_1_attribut2_1, 
                             src_1_attribut2_2, src_1_attribut3_1, src_1_attribut3_2,
                             src_1_attribut4_1, src_1_attribut4_2, src_1_attribut5_1,
                             src_1_attribut5_2, cjchoice_1, cjrating_1_1, cjrating_1_2, 
                             cjchoice_2, cjrating_2_1, cjrating_2_2, cjchoice_3, 
                             cjrating_3_1, cjrating_3_2, cjchoice_4, cjrating_4_1,
                             cjrating_4_2))
colnames(df5)

df5$Scr_Conjoint = 5
colnames(df5)[which(names(df5) == "src_5_attribut1_1")] <- "attribut1_1"
colnames(df5)[which(names(df5) == "src_5_attribut1_2")] <- "attribut1_2"
colnames(df5)[which(names(df5) == "src_5_attribut2_1")] <- "attribut2_1"
colnames(df5)[which(names(df5) == "src_5_attribut2_2")] <- "attribut2_2"
colnames(df5)[which(names(df5) == "src_5_attribut3_1")] <- "attribut3_1"
colnames(df5)[which(names(df5) == "src_5_attribut3_2")] <- "attribut3_2"
colnames(df5)[which(names(df5) == "src_5_attribut4_1")] <- "attribut4_1"
colnames(df5)[which(names(df5) == "src_5_attribut4_2")] <- "attribut4_2"
colnames(df5)[which(names(df5) == "src_5_attribut5_1")] <- "attribut5_1"
colnames(df5)[which(names(df5) == "src_5_attribut5_2")] <- "attribut5_2"
colnames(df5)[which(names(df5) == "cjrating_5_1")] <- "C1_rating"
colnames(df5)[which(names(df5) == "cjrating_5_2")] <- "C2_rating"
colnames(df5)[which(names(df5) == "cjchoice_5")] <- "CJ_Choice"
colnames(df5)

# Merge dataframes
CJ <- rbind(df1, df2, df3, df4, df5)
colnames(CJ)

CJ$Ratingchoice <- ifelse(CJ$C1_rating > CJ$C2_rating, 1, 
                          ifelse(CJ$C1_rating < CJ$C2_rating, 2, 0))
table(CJ$Ratingchoice)

CJ$choiceright_strict <- ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 1, 1, 
                                ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 2, 1, 
                                       ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 2, 0, 
                                              ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 1, 0, 0))))
table(CJ$choiceright_strict)
prop.table(table(CJ$choiceright_strict))

CJ$choiceright_soft <- ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 1, 1, 
                              ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 2, 1, 
                                     ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 2, 0, 
                                            ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 1, 0, 1))))
table(CJ$choiceright_soft)
prop.table(table(CJ$choiceright_soft))



CJ$answer_comparison <- ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 1, "Same", 
                               ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 2, "Same", 
                                      ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 2, "Different", 
                                             ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 1, "Different", "Equal rating"))))

prop.table(table(CJ$answer_comparison))
prop.table(table(CJ$CJ_Choice, CJ$answer_comparison))

CJ_strict <- subset(CJ, CJ$choiceright_strict == 1)
CJ_soft <- subset(CJ, CJ$choiceright_soft == 1)

# Create one observation per candidate
df6 <- subset(CJ, select= -c(attribut1_2, attribut2_2, attribut3_2, attribut4_2, attribut5_2, C2_rating))
df6$Candidate_Num = 1
colnames(df6)[which(names(df6) == "attribut1_1")] <- "InstExp"
colnames(df6)[which(names(df6) == "attribut2_1")] <- "ExtExp"
colnames(df6)[which(names(df6) == "attribut3_1")] <- "Reason"
colnames(df6)[which(names(df6) == "attribut4_1")] <- "Migr"
colnames(df6)[which(names(df6) == "attribut5_1")] <- "Env"
colnames(df6)[which(names(df6) == "C1_rating")] <- "Rating"
colnames(df6)
df6$CJ_Choice <- ifelse(df6$Candidate_Num == 1 & df6$CJ_Choice == 1, 1, 0)
df6$CJ_Choice

df7 <- subset(CJ, select= -c(attribut1_1, attribut2_1, attribut3_1, attribut4_1, attribut5_1, C1_rating))
df7$Candidate_Num = 2
colnames(df7)[which(names(df7) == "attribut1_2")] <- "InstExp"
colnames(df7)[which(names(df7) == "attribut2_2")] <- "ExtExp"
colnames(df7)[which(names(df7) == "attribut3_2")] <- "Reason"
colnames(df7)[which(names(df7) == "attribut4_2")] <- "Migr"
colnames(df7)[which(names(df7) == "attribut5_2")] <- "Env"
colnames(df7)[which(names(df7) == "C2_rating")] <- "Rating"
colnames(df7)
df7$CJ_Choice <- ifelse(df7$Candidate_Num == 2 & df7$CJ_Choice == 2, 1, 0)
df7$CJ_Choice

Conjoint <- rbind(df6, df7)
colnames(Conjoint)

# Create variable for movement party voters

table(Conjoint$DK19)
attributes(Conjoint$DK19)
table(Conjoint$DE21)
attributes(Conjoint$DE21)
table(Conjoint$HU18)
attributes(Conjoint$HU18)
table(Conjoint$IT18)
attributes(Conjoint$IT18)
table(Conjoint$RO20)
attributes(Conjoint$RO20)
table(Conjoint$UK19)
attributes(Conjoint$UK19)
table(Conjoint$UK19_ni) 
attributes(Conjoint$UK19_ni)


Conjoint$movpartvoter <- ifelse(Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | 
                                  Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | 
                                  Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                  Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                  Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) |
                                  Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni), 
                                "Movement party voter", "Traditional party voter")
Conjoint$movpartvoter
Conjoint$movpartvoter <- as.factor(Conjoint$movpartvoter)

Conjoint$movpartypast <- ifelse(Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | 
                                  Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | 
                                  Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                  Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                  Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) |
                                  Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni), 1, 0)
Conjoint$movpartypast


Conjoint$GreenLeftpast <- ifelse(Conjoint$DK19 == 1 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | 
                                   Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 1 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | 
                                   Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 3 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                   Conjoint$HU18 == 5 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 5 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 7 & !is.na(Conjoint$IT18) | 
                                   Conjoint$RO20 == 1 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 7 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 2 & !is.na(Conjoint$UK19) |  
                                   Conjoint$UK19 == 4 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 5 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) |
                                   Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19_ni == 3 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$GreenLeftpast)

Conjoint$Rightpast <- ifelse(Conjoint$DK19 == 3 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 6 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 7 & !is.na(Conjoint$DK19) | 
                               Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 19 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 2 & !is.na(Conjoint$DE21) | 
                               Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 1 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | 
                               Conjoint$IT18 == 2 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 3 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 4 & !is.na(Conjoint$IT18) | 
                               Conjoint$RO20 == 2 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | 
                               Conjoint$RO20 == 6 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 1 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) | 
                               Conjoint$UK19_ni == 1 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19_ni == 1 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$Rightpast)


Conjoint$Centereclecticpast <- ifelse(Conjoint$DK19 == 2 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 5 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 8 & !is.na(Conjoint$DK19) | 
                                        Conjoint$DE21 == 5 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 7 & !is.na(Conjoint$HU18) | 
                                        Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 6 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                        Conjoint$RO20 == 9 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 3 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 5 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$Centereclecticpast)

Conjoint$Eclecticpast <- ifelse(Conjoint$IT18 == 1 & !is.na(Conjoint$IT18), 1, 0)
table(Conjoint$Eclecticpast)


Conjoint$Otherabstainpast <- ifelse(Conjoint$DK19 == 10 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 18 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 11 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 12 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 13 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 14 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 98 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 99 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DE21 == 8 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 9 & !is.na(Conjoint$DE21) | 
                                      Conjoint$DE21 == 7 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 10 & !is.na(Conjoint$DE21) | 
                                      Conjoint$DE21 == 98 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 99 & !is.na(Conjoint$DE21) | 
                                      Conjoint$HU18 == 996 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 997 & !is.na(Conjoint$HU18) | 
                                      Conjoint$HU18 == 998 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 999 & !is.na(Conjoint$HU18) | 
                                      Conjoint$HU18 == 998 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 999 & !is.na(Conjoint$HU18) | 
                                      Conjoint$IT18 == 99 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 98 & !is.na(Conjoint$IT18) |
                                      Conjoint$RO20 == 10 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 10 & !is.na(Conjoint$RO20) |                                      
                                      Conjoint$IT18 == 998 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 999 & !is.na(Conjoint$IT18) | 
                                      Conjoint$RO20 == 98 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 998 & !is.na(Conjoint$RO20) | 
                                      Conjoint$RO20 == 999 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 98 & !is.na(Conjoint$UK19) |  
                                      Conjoint$UK19 == 99 & !is.na(Conjoint$UK19) |  Conjoint$UK19 == 998 & !is.na(Conjoint$UK19) |  
                                      Conjoint$UK19_ni == 98 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19 == 99 & !is.na(Conjoint$UK19) | 
                                      Conjoint$UK19 == 998 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 999 & !is.na(Conjoint$UK19) | 
                                      Conjoint$UK19_ni == 998 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 999 & !is.na(Conjoint$UK19), 1, 0)
table(Conjoint$Otherabstainpast)



Conjoint$greenmovpartpast <- 0
Conjoint$greenmovpartpast[Conjoint$movpartypast == 1 & Conjoint$GreenLeftpast == 1] <- 1
table(Conjoint$greenmovpartpast)

Conjoint$lefttradpast <- 0
Conjoint$lefttradpast[Conjoint$movpartypast == 0 & Conjoint$GreenLeftpast == 1] <- 1
table(Conjoint$lefttradpast)

Conjoint$rightmovpartpast <- 0
Conjoint$rightmovpartpast[Conjoint$movpartypast == 1 & Conjoint$Rightpast == 1] <- 1
table(Conjoint$rightmovpartpast)

Conjoint$righttradpast <- 0
Conjoint$righttradpast[Conjoint$movpartypast == 0 & Conjoint$Rightpast == 1] <- 1
table(Conjoint$righttradpast)

Conjoint$Centereclecticmovpartpast <- 0
Conjoint$Centereclecticmovpartpast[(Conjoint$movpartypast == 1 & Conjoint$Centereclecticpast == 1) | 
                                     (Conjoint$movpartypast == 1 & Conjoint$Eclecticpast == 1)] <- 1
table(Conjoint$Centereclecticmovpartpast)

Conjoint$Centereclectictradpast <- 0
Conjoint$Centereclectictradpast[(Conjoint$movpartypast == 0 & Conjoint$Centereclecticpast == 1) |
                                  (Conjoint$movpartypast == 0 & Conjoint$Eclecticpast == 1)] <- 1
table(Conjoint$Centereclectictradpast)

Conjoint$Partyvotepast <- ifelse(Conjoint$greenmovpartpast == 1 & !is.na(Conjoint$greenmovpartpast), "Green/left libertarian movement party",
                                 ifelse(Conjoint$lefttradpast == 1 & !is.na(Conjoint$lefttradpast), "Left conventional party",
                                        ifelse(Conjoint$rightmovpartpast == 1 & !is.na(Conjoint$rightmovpartpast), "Radical right movement party",
                                               ifelse(Conjoint$righttradpast == 1 & !is.na(Conjoint$righttradpast), "Right-wing conventional party",
                                                      ifelse(Conjoint$Centereclectictradpast == 1 & !is.na(Conjoint$Centereclectictradpast), "Centrist conventional party",
                                                             ifelse(Conjoint$Centereclecticmovpartpast == 1 & !is.na(Conjoint$Centereclecticmovpartpast), "Centrist & eclectic movement party", "Abstention & Other parties"))))))

table(Conjoint$Partyvotepast)
Conjoint$Partyvotepast <- as.factor(Conjoint$Partyvotepast)

Conjoint$Partytypepast <- ifelse(Conjoint$movpartypast == 1, "Movement party", "Traditional party")
Conjoint$Partytypepast
Conjoint$Partytypepast <- as.factor(Conjoint$Partytypepast)

CJleft <- subset(Conjoint, Conjoint$GreenLeftpast == 1)
CJright <- subset(Conjoint, Conjoint$Rightpast == 1)
CJcentecc <- subset(Conjoint, Conjoint$Centereclecticpast == 1)
CJabs <- subset(Conjoint, Conjoint$Otherabstainpast == 1)

CJmovpart <- subset(Conjoint, Conjoint$movpartypast == 1)
CJmovpart$partid <- ifelse(CJmovpart$GreenLeftpast == 1 & !is.na(CJmovpart$GreenLeftpast == 1), "Green/left",
                           ifelse(CJmovpart$Rightpast == 1 & !is.na(CJmovpart$Rightpast == 1), "Radical Right",
                                  ifelse(CJmovpart$Centereclecticpast == 1 & !is.na(CJmovpart$Centereclecticpast == 1), "Center/Eclectic", 
                                         "Other/Abstain")))
table(CJmovpart$partid)
CJmovpart$partid
CJmovpart$partid [is.na(CJmovpart$partid)] <- "Other/Abstain"
table(CJmovpart$partid)
CJmovpart$partid <- as.factor(CJmovpart$partid)

CJtradpart <- subset(Conjoint, Conjoint$movpartypast == 0)
CJtradpart$partid <- ifelse(CJtradpart$GreenLeftpast == 1 & !is.na(CJtradpart$GreenLeftpast == 1), "Left-wing",
                            ifelse(CJtradpart$Rightpast == 1 & !is.na(CJtradpart$Rightpast == 1), "Right-wing",
                                   ifelse(CJtradpart$Centereclecticpast == 1 & !is.na(CJtradpart$Centereclectictradpast == 1), "Center/Eclectic", "Other/Abstentionist")))
table(CJtradpart$partid)
CJtradpart$partid <- as.factor(CJtradpart$partid)




##
###
#### ANALYSIS OF CONJOINT ####
###
##

##
### Candidate Choice
##

# Turn attributes into factors for Cregg package

Conjoint$CJ_InstExp <- NA
Conjoint$CJ_InstExp <- ifelse(Conjoint$InstExp == 1, "No institutional experience",
                              ifelse(Conjoint$InstExp == 2, "12 years in politics but never in government",
                                     ifelse(Conjoint$InstExp == 3, "12 years in politics and part in government", NA)))
Conjoint$CJ_InstExp <- as.factor(Conjoint$CJ_InstExp)

Conjoint$CJ_ExtExp <- NA
Conjoint$CJ_ExtExp <- ifelse(Conjoint$ExtExp == 1, "Protest experience",
                             ifelse(Conjoint$ExtExp == 2, "No extra-institutional experience",
                                    ifelse(Conjoint$ExtExp == 3, "Volunteering experience", NA)))
Conjoint$CJ_ExtExp <- as.factor(Conjoint$CJ_ExtExp)

Conjoint$CJ_Reason <- NA
Conjoint$CJ_Reason <- ifelse(Conjoint$Reason == 1, "Anti-elitist",
                             ifelse(Conjoint$Reason == 2, "Neutral",
                                    ifelse(Conjoint$Reason == 3, "Mainstream", NA)))
Conjoint$CJ_Reason <- as.factor(Conjoint$CJ_Reason)

Conjoint$CJ_Migr <- NA
Conjoint$CJ_Migr <- ifelse(Conjoint$Migr == 1, "Open borders to most migrants",
                           ifelse(Conjoint$Migr == 2, "Close borders to most migrants",
                                  ifelse(Conjoint$Migr == 3, "Maintain current migration policies", NA)))
Conjoint$CJ_Migr <- as.factor(Conjoint$CJ_Migr)

Conjoint$CJ_Env <- NA
Conjoint$CJ_Env <- ifelse(Conjoint$Env == 1, "Make climate change a priority",
                          ifelse(Conjoint$Env == 2, "Reverse climate change policies",
                                 ifelse(Conjoint$Env == 3, "Maintain current climate change policies", NA)))
Conjoint$CJ_Env <- as.factor(Conjoint$CJ_Env)
Conjoint$CJ_Env





#### Analysis of Marginal Means

# Movement party vs traditional party - All data

MM_Choice_movtrad_all <- cj(Conjoint, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all

write.excel(MM_Choice_movtrad_all)



# By party per attribute - Institutional experience

Conjoint$Vote <- Conjoint$Partyvotepast


MM_Choice_byparty_instexp <- cj(Conjoint, CJ_Choice ~ CJ_InstExp, 
                                id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp

write.excel(MM_Choice_byparty_instexp)


# By party per attribute - Extra-institutional experience

MM_Choice_byparty_extexp <- cj(Conjoint, CJ_Choice ~ CJ_ExtExp, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_extexp

write.excel(MM_Choice_byparty_extexp)


# By party per attribute - Reason for running


MM_Choice_byparty_reason <- cj(Conjoint, CJ_Choice ~ CJ_Reason, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_reason, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_reason, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))

MM_Choice_byparty_reason

write.excel(MM_Choice_byparty_reason)


# By party per attribute - Migration

MM_Choice_byparty_migr <- cj(Conjoint, CJ_Choice ~ CJ_Migr, 
                             id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr

write.excel(MM_Choice_byparty_migr)


# By party per attribute - Environment

MM_Choice_byparty_env <- cj(Conjoint, CJ_Choice ~ CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env

write.excel(MM_Choice_byparty_env)






########################################################################################################################
#### APPENDIX
########################################################################################################################


### Interactions between pairs of attributes


# Institutional experience with extra-institutional experience

Conjoint_noinstexp <- subset(Conjoint, Conjoint$CJ_InstExp == "No institutional experience")

Conjoint_nogov <- subset(Conjoint, Conjoint$CJ_InstExp == "12 years in politics but never in government")

Conjoint_govexp <- subset(Conjoint, Conjoint$CJ_InstExp == "12 years in politics and part in government")

MM_Choice_byparty_extexp_noinstexp <- cj(Conjoint_noinstexp, CJ_Choice ~ CJ_ExtExp, 
                                         id = ~ID, estimate = "mm", by = ~Vote)


noinstexpextexpplot <- plot(MM_Choice_byparty_extexp_noinstexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noinstexpextexpplot


MM_Choice_byparty_extexp_noinstexp

write.excel(MM_Choice_byparty_extexp_noinstexp)


MM_Choice_byparty_extexp_nogov <- cj(Conjoint_nogov, CJ_Choice ~ CJ_ExtExp, 
                                     id = ~ID, estimate = "mm", by = ~Vote)

nogovextexpplot <- plot(MM_Choice_byparty_extexp_nogov, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nogovextexpplot

MM_Choice_byparty_extexp_nogov

write.excel(MM_Choice_byparty_extexp_nogov)



MM_Choice_byparty_extexp_govexp <- cj(Conjoint_govexp, CJ_Choice ~ CJ_ExtExp, 
                                      id = ~ID, estimate = "mm", by = ~Vote)


govexpextexpplot <- plot(MM_Choice_byparty_extexp_govexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

govexpextexpplot


# Institutional experience with reasons for running

MM_Choice_byparty_reason_noinstexp <- cj(Conjoint_noinstexp, CJ_Choice ~ CJ_Reason, 
                                         id = ~ID, estimate = "mm", by = ~Vote)


noinstexpreasonplot <- plot(MM_Choice_byparty_reason_noinstexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noinstexpreasonplot


MM_Choice_byparty_reason_noinstexp

write.excel(MM_Choice_byparty_reason_noinstexp)


MM_Choice_byparty_reason_nogov <- cj(Conjoint_nogov, CJ_Choice ~ CJ_Reason, 
                                     id = ~ID, estimate = "mm", by = ~Vote)

nogovreasonplot <- plot(MM_Choice_byparty_reason_nogov, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nogovreasonplot

MM_Choice_byparty_reason_nogov

write.excel(MM_Choice_byparty_reason_nogov)



MM_Choice_byparty_reason_govexp <- cj(Conjoint_govexp, CJ_Choice ~ CJ_Reason, 
                                      id = ~ID, estimate = "mm", by = ~Vote)


govexpreasonplot <- plot(MM_Choice_byparty_reason_govexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

govexpreasonplot


# Institutional experience with position on migration

MM_Choice_byparty_migr_noinstexp <- cj(Conjoint_noinstexp, CJ_Choice ~ CJ_Migr, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


noinstexpmigrplot <- plot(MM_Choice_byparty_migr_noinstexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noinstexpmigrplot


MM_Choice_byparty_migr_noinstexp

write.excel(MM_Choice_byparty_migr_noinstexp)


MM_Choice_byparty_migr_nogov <- cj(Conjoint_nogov, CJ_Choice ~ CJ_Migr, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

nogovmigrplot <- plot(MM_Choice_byparty_migr_nogov, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nogovmigrplot

MM_Choice_byparty_migr_nogov

write.excel(MM_Choice_byparty_migr_nogov)



MM_Choice_byparty_migr_govexp <- cj(Conjoint_govexp, CJ_Choice ~ CJ_Migr, 
                                    id = ~ID, estimate = "mm", by = ~Vote)


govexpmigrplot <- plot(MM_Choice_byparty_migr_govexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

govexpmigrplot



# Institutional experience with position on the environment

MM_Choice_byparty_env_noinstexp <- cj(Conjoint_noinstexp, CJ_Choice ~ CJ_Env, 
                                      id = ~ID, estimate = "mm", by = ~Vote)


noinstexpenvplot <- plot(MM_Choice_byparty_env_noinstexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noinstexpenvplot


MM_Choice_byparty_env_noinstexp

write.excel(MM_Choice_byparty_env_noinstexp)


MM_Choice_byparty_env_nogov <- cj(Conjoint_nogov, CJ_Choice ~ CJ_Env, 
                                  id = ~ID, estimate = "mm", by = ~Vote)

nogovenvplot <- plot(MM_Choice_byparty_env_nogov, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nogovenvplot

MM_Choice_byparty_env_nogov

write.excel(MM_Choice_byparty_env_nogov)



MM_Choice_byparty_env_govexp <- cj(Conjoint_govexp, CJ_Choice ~ CJ_Env, 
                                   id = ~ID, estimate = "mm", by = ~Vote)


govexpenvplot <- plot(MM_Choice_byparty_env_govexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

govexpenvplot


# Extra-institutional experience with institutional experience

Conjoint_noextexp <- subset(Conjoint, Conjoint$CJ_ExtExp == "No extra-institutional experience")

Conjoint_volunteer <- subset(Conjoint, Conjoint$CJ_ExtExp == "Volunteering experience")

Conjoint_protexp <- subset(Conjoint, Conjoint$CJ_ExtExp == "Protest experience")

MM_Choice_byparty_instexp_noextexp <- cj(Conjoint_noextexp, CJ_Choice ~ CJ_InstExp, 
                                         id = ~ID, estimate = "mm", by = ~Vote)


noextexpinstexpplot <- plot(MM_Choice_byparty_instexp_noextexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noextexpinstexpplot


MM_Choice_byparty_instexp_noextexp

write.excel(MM_Choice_byparty_instexp_noextexp)


MM_Choice_byparty_instexp_volunteer <- cj(Conjoint_volunteer, CJ_Choice ~ CJ_InstExp, 
                                          id = ~ID, estimate = "mm", by = ~Vote)

volunteerinstexpplot <- plot(MM_Choice_byparty_instexp_volunteer, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

volunteerinstexpplot

MM_Choice_byparty_instexp_volunteer

write.excel(MM_Choice_byparty_instexp_volunteer)



MM_Choice_byparty_instexp_protexp <- cj(Conjoint_protexp, CJ_Choice ~ CJ_InstExp, 
                                        id = ~ID, estimate = "mm", by = ~Vote)


protexpinstexpplot <- plot(MM_Choice_byparty_instexp_protexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

protexpinstexpplot



# Institutional experience with reasons for running

MM_Choice_byparty_reason_noextexp <- cj(Conjoint_noextexp, CJ_Choice ~ CJ_Reason, 
                                        id = ~ID, estimate = "mm", by = ~Vote)


noextexpreasonplot <- plot(MM_Choice_byparty_reason_noextexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noextexpreasonplot


MM_Choice_byparty_reason_noextexp

write.excel(MM_Choice_byparty_reason_noextexp)


MM_Choice_byparty_reason_volunteer <- cj(Conjoint_volunteer, CJ_Choice ~ CJ_Reason, 
                                         id = ~ID, estimate = "mm", by = ~Vote)

volunteerreasonplot <- plot(MM_Choice_byparty_reason_volunteer, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

volunteerreasonplot

MM_Choice_byparty_reason_volunteer

write.excel(MM_Choice_byparty_reason_volunteer)



MM_Choice_byparty_reason_protexp <- cj(Conjoint_protexp, CJ_Choice ~ CJ_Reason, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


protexpreasonplot <- plot(MM_Choice_byparty_reason_protexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

protexpreasonplot


# Institutional experience with position on migration

MM_Choice_byparty_migr_noextexp <- cj(Conjoint_noextexp, CJ_Choice ~ CJ_Migr, 
                                      id = ~ID, estimate = "mm", by = ~Vote)


noextexpmigrplot <- plot(MM_Choice_byparty_migr_noextexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noextexpmigrplot


MM_Choice_byparty_migr_noextexp

write.excel(MM_Choice_byparty_migr_noextexp)


MM_Choice_byparty_migr_volunteer <- cj(Conjoint_volunteer, CJ_Choice ~ CJ_Migr, 
                                       id = ~ID, estimate = "mm", by = ~Vote)

volunteermigrplot <- plot(MM_Choice_byparty_migr_volunteer, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

volunteermigrplot

MM_Choice_byparty_migr_volunteer

write.excel(MM_Choice_byparty_migr_volunteer)



MM_Choice_byparty_migr_protexp <- cj(Conjoint_protexp, CJ_Choice ~ CJ_Migr, 
                                     id = ~ID, estimate = "mm", by = ~Vote)


protexpmigrplot <- plot(MM_Choice_byparty_migr_protexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

protexpmigrplot



# Institutional experience with position on the environment

MM_Choice_byparty_env_noextexp <- cj(Conjoint_noextexp, CJ_Choice ~ CJ_Env, 
                                     id = ~ID, estimate = "mm", by = ~Vote)


noextexpenvplot <- plot(MM_Choice_byparty_env_noextexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


noextexpenvplot


MM_Choice_byparty_env_noextexp

write.excel(MM_Choice_byparty_env_noextexp)


MM_Choice_byparty_env_volunteer <- cj(Conjoint_volunteer, CJ_Choice ~ CJ_Env, 
                                      id = ~ID, estimate = "mm", by = ~Vote)

volunteerenvplot <- plot(MM_Choice_byparty_env_volunteer, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

volunteerenvplot

MM_Choice_byparty_env_volunteer

write.excel(MM_Choice_byparty_env_volunteer)



MM_Choice_byparty_env_protexp <- cj(Conjoint_protexp, CJ_Choice ~ CJ_Env, 
                                    id = ~ID, estimate = "mm", by = ~Vote)


protexpenvplot <- plot(MM_Choice_byparty_env_protexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

protexpenvplot


# Reasons for running with institutional experience

Conjoint_neutral <- subset(Conjoint, Conjoint$CJ_Reason == "Neutral")

Conjoint_mainstream <- subset(Conjoint, Conjoint$CJ_Reason == "Mainstream")

Conjoint_antielitism <- subset(Conjoint, Conjoint$CJ_Reason == "Anti-elitist")


MM_Choice_byparty_instexp_neutral <- cj(Conjoint_neutral, CJ_Choice ~ CJ_InstExp, 
                                        id = ~ID, estimate = "mm", by = ~Vote)


neutralinstexpplot <- plot(MM_Choice_byparty_instexp_neutral, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

neutralinstexpplot


MM_Choice_byparty_instexp_neutral

write.excel(MM_Choice_byparty_instexp_neutral)


MM_Choice_byparty_instexp_mainstream <- cj(Conjoint_mainstream, CJ_Choice ~ CJ_InstExp, 
                                           id = ~ID, estimate = "mm", by = ~Vote)

mainstreaminstexpplot <- plot(MM_Choice_byparty_instexp_mainstream, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

mainstreaminstexpplot

MM_Choice_byparty_instexp_mainstream

write.excel(MM_Choice_byparty_instexp_mainstream)



MM_Choice_byparty_instexp_antielitism <- cj(Conjoint_antielitism, CJ_Choice ~ CJ_InstExp, 
                                            id = ~ID, estimate = "mm", by = ~Vote)


antielitisminstexpplot <- plot(MM_Choice_byparty_instexp_antielitism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

antielitisminstexpplot


# Reasons for running with extra-institutional experience

MM_Choice_byparty_extexp_neutral <- cj(Conjoint_neutral, CJ_Choice ~ CJ_ExtExp, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


neutralextexpplot <- plot(MM_Choice_byparty_extexp_neutral, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

neutralextexpplot


MM_Choice_byparty_extexp_neutral

write.excel(MM_Choice_byparty_extexp_neutral)


MM_Choice_byparty_extexp_mainstream <- cj(Conjoint_mainstream, CJ_Choice ~ CJ_ExtExp, 
                                          id = ~ID, estimate = "mm", by = ~Vote)

mainstreamextexpplot <- plot(MM_Choice_byparty_extexp_mainstream, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

mainstreamextexpplot

MM_Choice_byparty_extexp_mainstream

write.excel(MM_Choice_byparty_extexp_mainstream)



MM_Choice_byparty_extexp_antielitism <- cj(Conjoint_antielitism, CJ_Choice ~ CJ_ExtExp, 
                                           id = ~ID, estimate = "mm", by = ~Vote)


antielitismextexpplot <- plot(MM_Choice_byparty_extexp_antielitism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

antielitismextexpplot


# Reasons for running with position on migration

MM_Choice_byparty_migr_neutral <- cj(Conjoint_neutral, CJ_Choice ~ CJ_Migr, 
                                     id = ~ID, estimate = "mm", by = ~Vote)


neutralmigrplot <- plot(MM_Choice_byparty_migr_neutral, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

neutralmigrplot


MM_Choice_byparty_migr_neutral

write.excel(MM_Choice_byparty_migr_neutral)


MM_Choice_byparty_migr_mainstream <- cj(Conjoint_mainstream, CJ_Choice ~ CJ_Migr, 
                                        id = ~ID, estimate = "mm", by = ~Vote)

mainstreammigrplot <- plot(MM_Choice_byparty_migr_mainstream, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

mainstreammigrplot

MM_Choice_byparty_migr_mainstream

write.excel(MM_Choice_byparty_migr_mainstream)



MM_Choice_byparty_migr_antielitism <- cj(Conjoint_antielitism, CJ_Choice ~ CJ_Migr, 
                                         id = ~ID, estimate = "mm", by = ~Vote)


antielitismmigrplot <- plot(MM_Choice_byparty_migr_antielitism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

antielitismmigrplot


# Reasons for running with position on the environment

MM_Choice_byparty_env_neutral <- cj(Conjoint_neutral, CJ_Choice ~ CJ_Env, 
                                    id = ~ID, estimate = "mm", by = ~Vote)


neutralenvplot <- plot(MM_Choice_byparty_env_neutral, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

neutralenvplot


MM_Choice_byparty_env_neutral

write.excel(MM_Choice_byparty_env_neutral)


MM_Choice_byparty_env_mainstream <- cj(Conjoint_mainstream, CJ_Choice ~ CJ_Env, 
                                       id = ~ID, estimate = "mm", by = ~Vote)

mainstreamenvplot <- plot(MM_Choice_byparty_env_mainstream, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

mainstreamenvplot

MM_Choice_byparty_env_mainstream

write.excel(MM_Choice_byparty_env_mainstream)



MM_Choice_byparty_env_antielitism <- cj(Conjoint_antielitism, CJ_Choice ~ CJ_Env, 
                                        id = ~ID, estimate = "mm", by = ~Vote)


antielitismenvplot <- plot(MM_Choice_byparty_env_antielitism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

antielitismenvplot



# Migration with institutional experience

Conjoint$CJ_Migr

Conjoint_formigr <- subset(Conjoint, Conjoint$CJ_Migr == "Open borders to most migrants")

Conjoint_nomigr <- subset(Conjoint, Conjoint$CJ_Migr == "Close borders to most migrants")

Conjoint_samemigr <- subset(Conjoint, Conjoint$CJ_Migr == "Maintain current migration policies")

MM_Choice_byparty_instexp_formigr <- cj(Conjoint_formigr, CJ_Choice ~ CJ_InstExp, 
                                        id = ~ID, estimate = "mm", by = ~Vote)


formigrinstexpplot <- plot(MM_Choice_byparty_instexp_formigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

formigrinstexpplot


MM_Choice_byparty_instexp_formigr

write.excel(MM_Choice_byparty_instexp_formigr)


MM_Choice_byparty_instexp_nomigr <- cj(Conjoint_nomigr, CJ_Choice ~ CJ_InstExp, 
                                       id = ~ID, estimate = "mm", by = ~Vote)

nomigrinstexpplot <- plot(MM_Choice_byparty_instexp_nomigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nomigrinstexpplot

MM_Choice_byparty_instexp_nomigr

write.excel(MM_Choice_byparty_instexp_nomigr)



MM_Choice_byparty_instexp_samemigr <- cj(Conjoint_samemigr, CJ_Choice ~ CJ_InstExp, 
                                         id = ~ID, estimate = "mm", by = ~Vote)

samemigrinstexpplot <- plot(MM_Choice_byparty_instexp_samemigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


samemigrinstexpplot

MM_Choice_byparty_instexp_samemigr

write.excel(MM_Choice_byparty_instexp_samemigr)


# Migration with extra-institutional experience

MM_Choice_byparty_extexp_formigr <- cj(Conjoint_formigr, CJ_Choice ~ CJ_ExtExp, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


formigrextexpplot <- plot(MM_Choice_byparty_extexp_formigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

formigrextexpplot


MM_Choice_byparty_extexp_formigr

write.excel(MM_Choice_byparty_extexp_formigr)


MM_Choice_byparty_extexp_nomigr <- cj(Conjoint_nomigr, CJ_Choice ~ CJ_ExtExp, 
                                      id = ~ID, estimate = "mm", by = ~Vote)

nomigrextexpplot <- plot(MM_Choice_byparty_extexp_nomigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nomigrextexpplot

MM_Choice_byparty_extexp_nomigr

write.excel(MM_Choice_byparty_extexp_nomigr)



MM_Choice_byparty_extexp_samemigr <- cj(Conjoint_samemigr, CJ_Choice ~ CJ_ExtExp, 
                                        id = ~ID, estimate = "mm", by = ~Vote)

samemigrextexpplot <- plot(MM_Choice_byparty_extexp_samemigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


samemigrextexpplot

MM_Choice_byparty_extexp_samemigr

write.excel(MM_Choice_byparty_extexp_samemigr)


# Migration with reasons for running

MM_Choice_byparty_reason_formigr <- cj(Conjoint_formigr, CJ_Choice ~ CJ_Reason, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


formigrreasonplot <- plot(MM_Choice_byparty_reason_formigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

formigrreasonplot


MM_Choice_byparty_reason_formigr

write.excel(MM_Choice_byparty_reason_formigr)


MM_Choice_byparty_reason_nomigr <- cj(Conjoint_nomigr, CJ_Choice ~ CJ_Reason, 
                                      id = ~ID, estimate = "mm", by = ~Vote)

nomigrreasonplot <- plot(MM_Choice_byparty_reason_nomigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nomigrreasonplot

MM_Choice_byparty_reason_nomigr

write.excel(MM_Choice_byparty_reason_nomigr)



MM_Choice_byparty_reason_samemigr <- cj(Conjoint_samemigr, CJ_Choice ~ CJ_Reason, 
                                        id = ~ID, estimate = "mm", by = ~Vote)

samemigrreasonplot <- plot(MM_Choice_byparty_reason_samemigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


samemigrreasonplot

MM_Choice_byparty_reason_samemigr

write.excel(MM_Choice_byparty_reason_samemigr)


# Migration with Environment

MM_Choice_byparty_env_formigr <- cj(Conjoint_formigr, CJ_Choice ~ CJ_Env, 
                                    id = ~ID, estimate = "mm", by = ~Vote)


formigrenvplot <- plot(MM_Choice_byparty_env_formigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

formigrenvplot


MM_Choice_byparty_env_formigr

write.excel(MM_Choice_byparty_env_formigr)


MM_Choice_byparty_env_nomigr <- cj(Conjoint_nomigr, CJ_Choice ~ CJ_Env, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

nomigrenvplot <- plot(MM_Choice_byparty_env_nomigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

nomigrenvplot

MM_Choice_byparty_env_nomigr

write.excel(MM_Choice_byparty_env_nomigr)



MM_Choice_byparty_env_samemigr <- cj(Conjoint_samemigr, CJ_Choice ~ CJ_Env, 
                                     id = ~ID, estimate = "mm", by = ~Vote)

samemigrenvplot <- plot(MM_Choice_byparty_env_samemigr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.8)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))


samemigrenvplot

MM_Choice_byparty_env_samemigr

write.excel(MM_Choice_byparty_env_samemigr)



# Environment with institutional experience

Conjoint$CJ_Env

Conjoint_forenv <- subset(Conjoint, Conjoint$CJ_Env == "Make climate change a priority")

Conjoint_noenv <- subset(Conjoint, Conjoint$CJ_Env == "Reverse climate change policies")

Conjoint_sameenv <- subset(Conjoint, Conjoint$CJ_Env == "Maintain current climate change policies")

MM_Choice_byparty_instexp_forenv <- cj(Conjoint_forenv, CJ_Choice ~ CJ_InstExp, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


forenvinstexpplot <- plot(MM_Choice_byparty_instexp_forenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

forenvinstexpplot


MM_Choice_byparty_instexp_forenv

write.excel(MM_Choice_byparty_instexp_forenv)


MM_Choice_byparty_instexp_noenv <- cj(Conjoint_noenv, CJ_Choice ~ CJ_InstExp, 
                                      id = ~ID, estimate = "mm", by = ~Vote)

noenvinstexpplot <- plot(MM_Choice_byparty_instexp_noenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

noenvinstexpplot

MM_Choice_byparty_instexp_noenv

write.excel(MM_Choice_byparty_instexp_noenv)


MM_Choice_byparty_instexp_sameenv <- cj(Conjoint_sameenv, CJ_Choice ~ CJ_InstExp, 
                                        id = ~ID, estimate = "mm", by = ~Vote)


sameenvinstexpplot <- plot(MM_Choice_byparty_instexp_sameenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

sameenvinstexpplot


MM_Choice_byparty_instexp_sameenv

write.excel(MM_Choice_byparty_instexp_sameenv)


# Environment with extra-institutional experience

MM_Choice_byparty_extexp_forenv <- cj(Conjoint_forenv, CJ_Choice ~ CJ_ExtExp, 
                                      id = ~ID, estimate = "mm", by = ~Vote)


forenvextexpplot <- plot(MM_Choice_byparty_extexp_forenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

forenvextexpplot


MM_Choice_byparty_extexp_forenv

write.excel(MM_Choice_byparty_extexp_forenv)


MM_Choice_byparty_extexp_noenv <- cj(Conjoint_noenv, CJ_Choice ~ CJ_ExtExp, 
                                     id = ~ID, estimate = "mm", by = ~Vote)

noenvextexpplot <- plot(MM_Choice_byparty_extexp_noenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

noenvextexpplot

MM_Choice_byparty_extexp_noenv

write.excel(MM_Choice_byparty_extexp_noenv)


MM_Choice_byparty_extexp_sameenv <- cj(Conjoint_sameenv, CJ_Choice ~ CJ_ExtExp, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


sameenvextexpplot <- plot(MM_Choice_byparty_extexp_sameenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

sameenvextexpplot


MM_Choice_byparty_extexp_sameenv

write.excel(MM_Choice_byparty_extexp_sameenv)


# Environment with reasons for running

MM_Choice_byparty_reason_forenv <- cj(Conjoint_forenv, CJ_Choice ~ CJ_Reason, 
                                      id = ~ID, estimate = "mm", by = ~Vote)


forenvreasonplot <- plot(MM_Choice_byparty_reason_forenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

forenvreasonplot


MM_Choice_byparty_reason_forenv

write.excel(MM_Choice_byparty_reason_forenv)


MM_Choice_byparty_reason_noenv <- cj(Conjoint_noenv, CJ_Choice ~ CJ_Reason, 
                                     id = ~ID, estimate = "mm", by = ~Vote)

noenvreasonplot <- plot(MM_Choice_byparty_reason_noenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

noenvreasonplot

MM_Choice_byparty_reason_noenv

write.excel(MM_Choice_byparty_reason_noenv)


MM_Choice_byparty_reason_sameenv <- cj(Conjoint_sameenv, CJ_Choice ~ CJ_Reason, 
                                       id = ~ID, estimate = "mm", by = ~Vote)


sameenvreasonplot <- plot(MM_Choice_byparty_reason_sameenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

sameenvreasonplot


MM_Choice_byparty_reason_sameenv

write.excel(MM_Choice_byparty_reason_sameenv)


# Environment with Migration

MM_Choice_byparty_migr_forenv <- cj(Conjoint_forenv, CJ_Choice ~ CJ_Migr, 
                                    id = ~ID, estimate = "mm", by = ~Vote)


forenvmigrplot <- plot(MM_Choice_byparty_migr_forenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

forenvmigrplot


MM_Choice_byparty_migr_forenv

write.excel(MM_Choice_byparty_migr_forenv)


MM_Choice_byparty_migr_noenv <- cj(Conjoint_noenv, CJ_Choice ~ CJ_Migr, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

noenvmigrplot <- plot(MM_Choice_byparty_migr_noenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7))) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

noenvmigrplot

MM_Choice_byparty_migr_noenv

write.excel(MM_Choice_byparty_migr_noenv)


MM_Choice_byparty_migr_sameenv <- cj(Conjoint_sameenv, CJ_Choice ~ CJ_Migr, 
                                     id = ~ID, estimate = "mm", by = ~Vote)


sameenvmigrplot <- plot(MM_Choice_byparty_migr_sameenv, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  ggtitle("") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(0.7)),
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(text = element_text(size = 15)) +
  guides(col = guide_legend(ncol = 3))

sameenvmigrplot


MM_Choice_byparty_migr_sameenv

write.excel(MM_Choice_byparty_migr_sameenv)


### ROBUSTNESS CHECKS


##
### Candidate Rating
##

table(Conjoint$Rating)

#### Analysis of Marginal Means

# By party type - All data

MM_Choice_byparty_all <- cj(Conjoint, Rating ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                            id = ~ID, estimate = "mm")
plot(MM_Choice_byparty_all, feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 4, xlab= "Probability of selecting a candidate (Marginal Means)")

MM_Choice_byparty_all

# Movement party vs traditional party - All data

MM_Choice_movtrad_all <- cj(Conjoint, Rating ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 4, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))




MM_Choice_movtrad_all

write.excel(MM_Choice_movtrad_all)



# By party per attribute - All data

Conjoint$Vote <- Conjoint$Partyvotepast


MM_Choice_byparty_instexp <- cj(Conjoint, Rating ~ CJ_InstExp, 
                                id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 4, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp

write.excel(MM_Choice_byparty_instexp)



MM_Choice_byparty_extexp <- cj(Conjoint, Rating ~ CJ_ExtExp, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 4, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_extexp

write.excel(MM_Choice_byparty_extexp)



MM_Choice_byparty_populism <- cj(Conjoint, Rating ~ CJ_Reason, 
                                 id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 4, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism

write.excel(MM_Choice_byparty_populism)


MM_Choice_byparty_migr <- cj(Conjoint, Rating ~ CJ_Migr, 
                             id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 4, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr

write.excel(MM_Choice_byparty_migr)




MM_Choice_byparty_env <- cj(Conjoint, Rating ~ CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 4, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env

write.excel(MM_Choice_byparty_env)



#### Weighted analysis


# Movement party vs traditional party - All data

MM_Choice_movtrad_all <- cj(Conjoint, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Partytypepast, weights = ~W8)


plot(MM_Choice_movtrad_all, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all

write.excel(MM_Choice_movtrad_all)



# By party per attribute - All data

Conjoint$Vote <- Conjoint$Partyvotepast


MM_Choice_byparty_instexp <- cj(Conjoint, CJ_Choice ~ CJ_InstExp, 
                                id = ~ID, estimate = "mm", by = ~Vote, weights = ~W8)

plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp

write.excel(MM_Choice_byparty_instexp)



MM_Choice_byparty_extexp <- cj(Conjoint, CJ_Choice ~ CJ_ExtExp, 
                               id = ~ID, estimate = "mm", by = ~Vote, weights = ~W8)
plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_extexp

write.excel(MM_Choice_byparty_extexp)



MM_Choice_byparty_populism <- cj(Conjoint, CJ_Choice ~ CJ_Reason, 
                                 id = ~ID, estimate = "mm", by = ~Vote, weights = ~W8)
plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism

write.excel(MM_Choice_byparty_populism)


MM_Choice_byparty_migr <- cj(Conjoint, CJ_Choice ~ CJ_Migr, 
                             id = ~ID, estimate = "mm", by = ~Vote, weights = ~W8)
plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr

write.excel(MM_Choice_byparty_migr)




MM_Choice_byparty_env <- cj(Conjoint, CJ_Choice ~ CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Vote, weights = ~W8)
plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env

write.excel(MM_Choice_byparty_env)








##
### Analysis per country
##

Conjoint_DE <- subset(Conjoint, Conjoint$country == "DE")
Conjoint_DK <- subset(Conjoint, Conjoint$country == "DK")
Conjoint_HU <- subset(Conjoint, Conjoint$country == "HU")
Conjoint_IT <- subset(Conjoint, Conjoint$country == "IT")
Conjoint_RO <- subset(Conjoint, Conjoint$country == "RO")
Conjoint_UK <- subset(Conjoint, Conjoint$country == "UK")


# Germany

# Movement party vs traditional party - All data

MM_Choice_movtrad_all_DE <- cj(Conjoint_DE, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all_DE, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all_DE

write.excel(MM_Choice_movtrad_all_DE)



# By party per attribute - All data

table(Conjoint_DE$party)
Conjoint_DE$Partyvotepast <- droplevels(Conjoint_DE$Partyvotepast)
Conjoint_DE$Vote <- Conjoint_DE$Partyvotepast


MM_Choice_byparty_instexp_DE <- cj(Conjoint_DE, CJ_Choice ~ CJ_InstExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp_DE

write.excel(MM_Choice_byparty_instexp_DE)



MM_Choice_byparty_exttexp_DE <- cj(Conjoint_DE, CJ_Choice ~ CJ_ExtExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_exttexp_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_exttexp_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_exttexp_DE

write.excel(MM_Choice_byparty_exttexp_DE)



MM_Choice_byparty_populism_DE <- cj(Conjoint_DE, CJ_Choice ~ CJ_Reason, 
                                    id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism_DE

write.excel(MM_Choice_byparty_populism_DE)


MM_Choice_byparty_migr_DE <- cj(Conjoint_DE, CJ_Choice ~ CJ_Migr, 
                                id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr_DE

write.excel(MM_Choice_byparty_migr_DE)




MM_Choice_byparty_env_DE <- cj(Conjoint_DE, CJ_Choice ~ CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env_DE, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env_DE

write.excel(MM_Choice_byparty_env_DE)



# Denmark

# Movement party vs traditional party - All data

MM_Choice_movtrad_all_DK <- cj(Conjoint_DK, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all_DK, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all_DK

write.excel(MM_Choice_movtrad_all_DK)



# By party per attribute - All data
table(Conjoint_DK$Partyvotepast)
Conjoint_DK$Partyvotepast <- droplevels(Conjoint_DK$Partyvotepast)
Conjoint_DK$Vote <- Conjoint_DK$Partyvotepast


MM_Choice_byparty_instexp_DK <- cj(Conjoint_DK, CJ_Choice ~ CJ_InstExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp_DK

write.excel(MM_Choice_byparty_instexp_DK)



MM_Choice_byparty_exttexp_DK <- cj(Conjoint_DK, CJ_Choice ~ CJ_ExtExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_exttexp_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_exttexp_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_exttexp_DK

write.excel(MM_Choice_byparty_exttexp_DK)



MM_Choice_byparty_populism_DK <- cj(Conjoint_DK, CJ_Choice ~ CJ_Reason, 
                                    id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism_DK

write.excel(MM_Choice_byparty_populism_DK)


MM_Choice_byparty_migr_DK <- cj(Conjoint_DK, CJ_Choice ~ CJ_Migr, 
                                id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr_DK

write.excel(MM_Choice_byparty_migr_DK)




MM_Choice_byparty_env_DK <- cj(Conjoint_DK, CJ_Choice ~ CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env_DK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env_DK

write.excel(MM_Choice_byparty_env_DK)


# Hungary

# Movement party vs traditional party - All data

MM_Choice_movtrad_all_HU <- cj(Conjoint_HU, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all_HU, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all_HU

write.excel(MM_Choice_movtrad_all_HU)



# By party per attribute - All data

table(Conjoint_HU$Partyvotepast)
Conjoint_HU$Partyvotepast <- droplevels(Conjoint_HU$Partyvotepast)
Conjoint_HU$Vote <- Conjoint_HU$Partyvotepast


MM_Choice_byparty_instexp_HU <- cj(Conjoint_HU, CJ_Choice ~ CJ_InstExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp_HU

write.excel(MM_Choice_byparty_instexp_HU)



MM_Choice_byparty_exttexp_HU <- cj(Conjoint_HU, CJ_Choice ~ CJ_ExtExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_exttexp_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_exttexp_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_exttexp_HU

write.excel(MM_Choice_byparty_exttexp_HU)



MM_Choice_byparty_populism_HU <- cj(Conjoint_HU, CJ_Choice ~ CJ_Reason, 
                                    id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism_HU

write.excel(MM_Choice_byparty_populism_HU)


MM_Choice_byparty_migr_HU <- cj(Conjoint_HU, CJ_Choice ~ CJ_Migr, 
                                id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr_HU

write.excel(MM_Choice_byparty_migr_HU)




MM_Choice_byparty_env_HU <- cj(Conjoint_HU, CJ_Choice ~ CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env_HU, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env_HU

write.excel(MM_Choice_byparty_env_HU)



# Italy

# Movement party vs traditional party - All data

MM_Choice_movtrad_all_IT <- cj(Conjoint_IT, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all_IT, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all_IT

write.excel(MM_Choice_movtrad_all_IT)



# By party per attribute - All data

table(Conjoint_IT$Partyvotepast)
Conjoint_IT$Partyvotepast <- droplevels(Conjoint_IT$Partyvotepast)
Conjoint_IT$Vote <- Conjoint_IT$Partyvotepast


MM_Choice_byparty_instexp_IT <- cj(Conjoint_IT, CJ_Choice ~ CJ_InstExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Left conventional party", 
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "skyblue3", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Left conventional party", 
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp_IT

write.excel(MM_Choice_byparty_instexp_IT)



MM_Choice_byparty_exttexp_IT <- cj(Conjoint_IT, CJ_Choice ~ CJ_ExtExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_exttexp_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_exttexp_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Left conventional party", 
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "skyblue3", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Left conventional party", 
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_exttexp_IT

write.excel(MM_Choice_byparty_exttexp_IT)



MM_Choice_byparty_populism_IT <- cj(Conjoint_IT, CJ_Choice ~ CJ_Reason, 
                                    id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Left conventional party", 
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "skyblue3", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Left conventional party", 
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism_IT

write.excel(MM_Choice_byparty_populism_IT)


MM_Choice_byparty_migr_IT <- cj(Conjoint_IT, CJ_Choice ~ CJ_Migr, 
                                id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Left conventional party", 
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "skyblue3", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Left conventional party", 
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr_IT

write.excel(MM_Choice_byparty_migr_IT)




MM_Choice_byparty_env_IT <- cj(Conjoint_IT, CJ_Choice ~ CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env_IT, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Left conventional party", 
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "skyblue3", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Left conventional party", 
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env_IT

write.excel(MM_Choice_byparty_env_IT)


# Romania

# Movement party vs traditional party - All data

MM_Choice_movtrad_all_RO <- cj(Conjoint_RO, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all_RO, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all_RO

write.excel(MM_Choice_movtrad_all_RO)



# By party per attribute - All data

table(Conjoint_RO$Partyvotepast)
Conjoint_RO$Partyvotepast <- droplevels(Conjoint_RO$Partyvotepast)
Conjoint_RO$Vote <- Conjoint_RO$Partyvotepast


MM_Choice_byparty_instexp_RO <- cj(Conjoint_RO, CJ_Choice ~ CJ_InstExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp_RO

write.excel(MM_Choice_byparty_instexp_RO)



MM_Choice_byparty_exttexp_RO <- cj(Conjoint_RO, CJ_Choice ~ CJ_ExtExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_exttexp_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_exttexp_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_exttexp_RO

write.excel(MM_Choice_byparty_exttexp_RO)



MM_Choice_byparty_populism_RO <- cj(Conjoint_RO, CJ_Choice ~ CJ_Reason, 
                                    id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism_RO

write.excel(MM_Choice_byparty_populism_RO)


MM_Choice_byparty_migr_RO <- cj(Conjoint_RO, CJ_Choice ~ CJ_Migr, 
                                id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr_RO

write.excel(MM_Choice_byparty_migr_RO)




MM_Choice_byparty_env_RO <- cj(Conjoint_RO, CJ_Choice ~ CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env_RO, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env_RO

write.excel(MM_Choice_byparty_env_RO)




# United Kingdom

# Movement party vs traditional party - All data

MM_Choice_movtrad_all_UK <- cj(Conjoint_UK, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all_UK, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))


MM_Choice_movtrad_all_UK

write.excel(MM_Choice_movtrad_all_UK)



# By party per attribute - All data

table(Conjoint_UK$Partyvotepast)
Conjoint_UK$Partyvotepast <- droplevels(Conjoint_UK$Partyvotepast)
Conjoint_UK$Vote <- Conjoint_UK$Partyvotepast


MM_Choice_byparty_instexp_UK <- cj(Conjoint_UK, CJ_Choice ~ CJ_InstExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp_UK

write.excel(MM_Choice_byparty_instexp_UK)



MM_Choice_byparty_exttexp_UK <- cj(Conjoint_UK, CJ_Choice ~ CJ_ExtExp, 
                                   id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_exttexp_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_exttexp_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_exttexp_UK

write.excel(MM_Choice_byparty_exttexp_UK)



MM_Choice_byparty_populism_UK <- cj(Conjoint_UK, CJ_Choice ~ CJ_Reason, 
                                    id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 80, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism_UK

write.excel(MM_Choice_byparty_populism_UK)


MM_Choice_byparty_migr_UK <- cj(Conjoint_UK, CJ_Choice ~ CJ_Migr, 
                                id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 200, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr_UK

write.excel(MM_Choice_byparty_migr_UK)




MM_Choice_byparty_env_UK <- cj(Conjoint_UK, CJ_Choice ~ CJ_Env, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env_UK, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env_UK

write.excel(MM_Choice_byparty_env_UK)





##
### Eliminating observations
##


CJ$Ratingchoice <- ifelse(CJ$C1_rating > CJ$C2_rating, 1, 
                          ifelse(CJ$C1_rating < CJ$C2_rating, 2, 0))
table(CJ$Ratingchoice)

CJ$choiceright_strict <- ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 1, 1, 
                                ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 2, 1, 
                                       ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 2, 0, 
                                              ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 1, 0, 0))))
table(CJ$choiceright_strict)
prop.table(table(CJ$choiceright_strict))

CJ$choiceright_soft <- ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 1, 1, 
                              ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 2, 1, 
                                     ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 2, 0, 
                                            ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 1, 0, 1))))
table(CJ$choiceright_soft)

CJ$answer_comparison <- ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 1, "Same", 
                               ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 2, "Same", 
                                      ifelse(CJ$CJ_Choice == 1 & CJ$Ratingchoice == 2, "Different", 
                                             ifelse(CJ$CJ_Choice == 2 & CJ$Ratingchoice == 1, "Different", "Equal rating"))))

prop.table(table(CJ$answer_comparison))
prop.table(table(CJ$CJ_Choice, CJ$answer_comparison))

CJ_strict <- subset(CJ, CJ$choiceright_strict == 1)
CJ_soft <- subset(CJ, CJ$choiceright_soft == 1)



## Eliminate observations in which the rating of the selected candidate is lower than the one of the discarded one

# Create one observation per candidate
df6 <- subset(CJ_soft, select= -c(attribut1_2, attribut2_2, attribut3_2, attribut4_2, attribut5_2, C2_rating))
df6$Candidate_Num = 1
colnames(df6)[which(names(df6) == "attribut1_1")] <- "InstExp"
colnames(df6)[which(names(df6) == "attribut2_1")] <- "ExtExp"
colnames(df6)[which(names(df6) == "attribut3_1")] <- "Reason"
colnames(df6)[which(names(df6) == "attribut4_1")] <- "Migr"
colnames(df6)[which(names(df6) == "attribut5_1")] <- "Env"
colnames(df6)[which(names(df6) == "C1_rating")] <- "Rating"
colnames(df6)
df6$CJ_Choice <- ifelse(df6$Candidate_Num == 1 & df6$CJ_Choice == 1, 1, 0)
df6$CJ_Choice

df7 <- subset(CJ_soft, select= -c(attribut1_1, attribut2_1, attribut3_1, attribut4_1, attribut5_1, C1_rating))
df7$Candidate_Num = 2
colnames(df7)[which(names(df7) == "attribut1_2")] <- "InstExp"
colnames(df7)[which(names(df7) == "attribut2_2")] <- "ExtExp"
colnames(df7)[which(names(df7) == "attribut3_2")] <- "Reason"
colnames(df7)[which(names(df7) == "attribut4_2")] <- "Migr"
colnames(df7)[which(names(df7) == "attribut5_2")] <- "Env"
colnames(df7)[which(names(df7) == "C2_rating")] <- "Rating"
colnames(df7)
df7$CJ_Choice <- ifelse(df7$Candidate_Num == 2 & df7$CJ_Choice == 2, 1, 0)
df7$CJ_Choice

Conjoint <- rbind(df6, df7)
colnames(Conjoint)


# Create variable for movement party voters
table(Conjoint$DK19)
table(Conjoint$DE21)
table(Conjoint$HU18)
table(Conjoint$IT18)
table(Conjoint$RO20)
table(Conjoint$UK19)
table(Conjoint$UK19_ni) 


Conjoint$DK19
Conjoint$DE21
Conjoint$HU18
Conjoint$IT18
Conjoint$RO20
Conjoint$UK19
Conjoint$UK19_ni

Conjoint$CJ_InstExp <- NA
Conjoint$CJ_InstExp <- ifelse(Conjoint$InstExp == 1, "No institutional experience",
                              ifelse(Conjoint$InstExp == 2, "12 years in politics but never in government",
                                     ifelse(Conjoint$InstExp == 3, "12 years in politics and part in government", NA)))

Conjoint$movpartvoter <- ifelse(Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | 
                                  Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | 
                                  Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                  Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                  Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) |
                                  Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni), 
                                "Movement party voter", "Traditional party voter")
Conjoint$movpartvoter
Conjoint$movpartvoter <- as.factor(Conjoint$movpartvoter)

Conjoint$movpartypast <- ifelse(Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | 
                                  Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | 
                                  Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                  Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                  Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) |
                                  Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni), 1, 0)
Conjoint$movpartypast


Conjoint$GreenLeftpast <- ifelse(Conjoint$DK19 == 1 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | 
                                   Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 1 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | 
                                   Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 3 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                   Conjoint$HU18 == 5 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 5 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 7 & !is.na(Conjoint$IT18) | 
                                   Conjoint$RO20 == 1 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 7 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 2 & !is.na(Conjoint$UK19) |  
                                   Conjoint$UK19 == 4 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 5 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) |
                                   Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19_ni == 3 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$GreenLeftpast)

Conjoint$Rightpast <- ifelse(Conjoint$DK19 == 3 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 6 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 7 & !is.na(Conjoint$DK19) | 
                               Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 19 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 2 & !is.na(Conjoint$DE21) | 
                               Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 1 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | 
                               Conjoint$IT18 == 2 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 3 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 4 & !is.na(Conjoint$IT18) | 
                               Conjoint$RO20 == 2 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | 
                               Conjoint$RO20 == 6 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 1 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) | 
                               Conjoint$UK19_ni == 1 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19_ni == 1 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$Rightpast)


Conjoint$Centereclecticpast <- ifelse(Conjoint$DK19 == 2 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 5 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 8 & !is.na(Conjoint$DK19) | 
                                        Conjoint$DE21 == 5 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 7 & !is.na(Conjoint$HU18) | 
                                        Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 6 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                        Conjoint$RO20 == 9 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 3 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 5 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$Centereclecticpast)

Conjoint$Eclecticpast <- ifelse(Conjoint$IT18 == 1 & !is.na(Conjoint$IT18), 1, 0)
table(Conjoint$Eclecticpast)


Conjoint$Otherabstainpast <- ifelse(Conjoint$DK19 == 10 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 18 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 11 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 12 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 13 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 14 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 98 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 99 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DE21 == 8 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 9 & !is.na(Conjoint$DE21) | 
                                      Conjoint$DE21 == 7 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 10 & !is.na(Conjoint$DE21) | 
                                      Conjoint$DE21 == 98 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 99 & !is.na(Conjoint$DE21) | 
                                      Conjoint$HU18 == 996 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 997 & !is.na(Conjoint$HU18) | 
                                      Conjoint$HU18 == 998 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 999 & !is.na(Conjoint$HU18) | 
                                      Conjoint$HU18 == 998 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 999 & !is.na(Conjoint$HU18) | 
                                      Conjoint$IT18 == 99 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 98 & !is.na(Conjoint$IT18) |
                                      Conjoint$RO20 == 10 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 10 & !is.na(Conjoint$RO20) |                                      
                                      Conjoint$IT18 == 998 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 999 & !is.na(Conjoint$IT18) | 
                                      Conjoint$RO20 == 98 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 998 & !is.na(Conjoint$RO20) | 
                                      Conjoint$RO20 == 999 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 98 & !is.na(Conjoint$UK19) |  
                                      Conjoint$UK19 == 99 & !is.na(Conjoint$UK19) |  Conjoint$UK19 == 998 & !is.na(Conjoint$UK19) |  
                                      Conjoint$UK19_ni == 98 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19 == 99 & !is.na(Conjoint$UK19) | 
                                      Conjoint$UK19 == 998 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 999 & !is.na(Conjoint$UK19) | 
                                      Conjoint$UK19_ni == 998 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 999 & !is.na(Conjoint$UK19), 1, 0)
table(Conjoint$Otherabstainpast)



Conjoint$greenmovpartpast <- 0
Conjoint$greenmovpartpast[Conjoint$movpartypast == 1 & Conjoint$GreenLeftpast == 1] <- 1
table(Conjoint$greenmovpartpast)

Conjoint$lefttradpast <- 0
Conjoint$lefttradpast[Conjoint$movpartypast == 0 & Conjoint$GreenLeftpast == 1] <- 1
table(Conjoint$lefttradpast)

Conjoint$rightmovpartpast <- 0
Conjoint$rightmovpartpast[Conjoint$movpartypast == 1 & Conjoint$Rightpast == 1] <- 1
table(Conjoint$rightmovpartpast)

Conjoint$righttradpast <- 0
Conjoint$righttradpast[Conjoint$movpartypast == 0 & Conjoint$Rightpast == 1] <- 1
table(Conjoint$righttradpast)

Conjoint$Centereclecticmovpartpast <- 0
Conjoint$Centereclecticmovpartpast[(Conjoint$movpartypast == 1 & Conjoint$Centereclecticpast == 1) | 
                                     (Conjoint$movpartypast == 1 & Conjoint$Eclecticpast == 1)] <- 1
table(Conjoint$Centereclecticmovpartpast)

Conjoint$Centereclectictradpast <- 0
Conjoint$Centereclectictradpast[(Conjoint$movpartypast == 0 & Conjoint$Centereclecticpast == 1) |
                                  (Conjoint$movpartypast == 0 & Conjoint$Eclecticpast == 1)] <- 1
table(Conjoint$Centereclectictradpast)

Conjoint$Partyvotepast <- ifelse(Conjoint$greenmovpartpast == 1 & !is.na(Conjoint$greenmovpartpast), "Green/left libertarian movement party",
                                 ifelse(Conjoint$lefttradpast == 1 & !is.na(Conjoint$lefttradpast), "Left conventional party",
                                        ifelse(Conjoint$rightmovpartpast == 1 & !is.na(Conjoint$rightmovpartpast), "Radical right movement party",
                                               ifelse(Conjoint$righttradpast == 1 & !is.na(Conjoint$righttradpast), "Right-wing conventional party",
                                                      ifelse(Conjoint$Centereclectictradpast == 1 & !is.na(Conjoint$Centereclectictradpast), "Centrist conventional party",
                                                             ifelse(Conjoint$Centereclecticmovpartpast == 1 & !is.na(Conjoint$Centereclecticmovpartpast), "Centrist & eclectic movement party", "Abstention & Other parties"))))))

table(Conjoint$Partyvotepast)
Conjoint$Partyvotepast <- as.factor(Conjoint$Partyvotepast)

Conjoint$Partytypepast <- ifelse(Conjoint$movpartypast == 1, "Movement party", "Traditional party")
Conjoint$Partytypepast
Conjoint$Partytypepast <- as.factor(Conjoint$Partytypepast)

CJleft <- subset(Conjoint, Conjoint$GreenLeftpast == 1)
CJright <- subset(Conjoint, Conjoint$Rightpast == 1)
CJcentecc <- subset(Conjoint, Conjoint$Centereclecticpast == 1)
CJabs <- subset(Conjoint, Conjoint$Otherabstainpast == 1)

CJmovpart <- subset(Conjoint, Conjoint$movpartypast == 1)
CJmovpart$partid <- ifelse(CJmovpart$GreenLeftpast == 1 & !is.na(CJmovpart$GreenLeftpast == 1), "Green/left",
                           ifelse(CJmovpart$Rightpast == 1 & !is.na(CJmovpart$Rightpast == 1), "Radical Right",
                                  ifelse(CJmovpart$Centereclecticpast == 1 & !is.na(CJmovpart$Centereclecticpast == 1), "Center/Eclectic", 
                                         "Other/Abstain")))
table(CJmovpart$partid)
CJmovpart$partid
CJmovpart$partid [is.na(CJmovpart$partid)] <- "Other/Abstain"
table(CJmovpart$partid)
CJmovpart$partid <- as.factor(CJmovpart$partid)

CJtradpart <- subset(Conjoint, Conjoint$movpartypast == 0)
CJtradpart$partid <- ifelse(CJtradpart$GreenLeftpast == 1 & !is.na(CJtradpart$GreenLeftpast == 1), "Left-wing",
                            ifelse(CJtradpart$Rightpast == 1 & !is.na(CJtradpart$Rightpast == 1), "Right-wing",
                                   ifelse(CJtradpart$Centereclecticpast == 1 & !is.na(CJtradpart$Centereclectictradpast == 1), "Center/Eclectic", "Other/Abstentionist")))
table(CJtradpart$partid)
CJtradpart$partid <- as.factor(CJtradpart$partid)



# Turn attributes into factors for Cregg package

Conjoint$CJ_InstExp <- NA
Conjoint$CJ_InstExp <- ifelse(Conjoint$InstExp == 1, "No institutional experience",
                              ifelse(Conjoint$InstExp == 2, "12 years in politics but never in government",
                                     ifelse(Conjoint$InstExp == 3, "12 years in politics and part in government", NA)))
Conjoint$CJ_InstExp <- as.factor(Conjoint$CJ_InstExp)

Conjoint$CJ_ExtExp <- NA
Conjoint$CJ_ExtExp <- ifelse(Conjoint$ExtExp == 1, "Protest experience",
                             ifelse(Conjoint$ExtExp == 2, "No extra-institutional experience",
                                    ifelse(Conjoint$ExtExp == 3, "Volunteering experience", NA)))
Conjoint$CJ_ExtExp <- as.factor(Conjoint$CJ_ExtExp)

Conjoint$CJ_Reason <- NA
Conjoint$CJ_Reason <- ifelse(Conjoint$Reason == 1, "Anti-elitist",
                             ifelse(Conjoint$Reason == 2, "Neutral",
                                    ifelse(Conjoint$Reason == 3, "Mainstream", NA)))
Conjoint$CJ_Reason <- as.factor(Conjoint$CJ_Reason)

Conjoint$CJ_Migr <- NA
Conjoint$CJ_Migr <- ifelse(Conjoint$Migr == 1, "Open borders to most migrants",
                           ifelse(Conjoint$Migr == 2, "Close borders to most migrants",
                                  ifelse(Conjoint$Migr == 3, "Maintain current migration policies", NA)))
Conjoint$CJ_Migr <- as.factor(Conjoint$CJ_Migr)

Conjoint$CJ_Env <- NA
Conjoint$CJ_Env <- ifelse(Conjoint$Env == 1, "Make climate change a priority",
                          ifelse(Conjoint$Env == 2, "Reverse climate change policies",
                                 ifelse(Conjoint$Env == 3, "Maintain current climate change policies", NA)))
Conjoint$CJ_Env <- as.factor(Conjoint$CJ_Env)
Conjoint$CJ_Env




#### Analysis of Marginal Means


# Movement party vs traditional party - All data

MM_Choice_movtrad_all <- cj(Conjoint, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))




MM_Choice_movtrad_all

write.excel(MM_Choice_movtrad_all)



# By party per attribute - All data

Conjoint$Vote <- Conjoint$Partyvotepast


MM_Choice_byparty_instexp <- cj(Conjoint, CJ_Choice ~ CJ_InstExp, 
                                id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp

write.excel(MM_Choice_byparty_instexp)



MM_Choice_byparty_extexp <- cj(Conjoint, CJ_Choice ~ CJ_ExtExp, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_extexp

write.excel(MM_Choice_byparty_extexp)



MM_Choice_byparty_populism <- cj(Conjoint, CJ_Choice ~ CJ_Reason, 
                                 id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism

write.excel(MM_Choice_byparty_populism)


MM_Choice_byparty_migr <- cj(Conjoint, CJ_Choice ~ CJ_Migr, 
                             id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr

write.excel(MM_Choice_byparty_migr)




MM_Choice_byparty_env <- cj(Conjoint, CJ_Choice ~ CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_env

write.excel(MM_Choice_byparty_env)



### Eliminate observations in which the rating of the selected candidate is equal or lower than the one of the discarded one

# Create one observation per candidate
df6 <- subset(CJ_strict, select= -c(attribut1_2, attribut2_2, attribut3_2, attribut4_2, attribut5_2, C2_rating))
df6$Candidate_Num = 1
colnames(df6)[which(names(df6) == "attribut1_1")] <- "InstExp"
colnames(df6)[which(names(df6) == "attribut2_1")] <- "ExtExp"
colnames(df6)[which(names(df6) == "attribut3_1")] <- "Reason"
colnames(df6)[which(names(df6) == "attribut4_1")] <- "Migr"
colnames(df6)[which(names(df6) == "attribut5_1")] <- "Env"
colnames(df6)[which(names(df6) == "C1_rating")] <- "Rating"
colnames(df6)
df6$CJ_Choice <- ifelse(df6$Candidate_Num == 1 & df6$CJ_Choice == 1, 1, 0)
df6$CJ_Choice

df7 <- subset(CJ_strict, select= -c(attribut1_1, attribut2_1, attribut3_1, attribut4_1, attribut5_1, C1_rating))
df7$Candidate_Num = 2
colnames(df7)[which(names(df7) == "attribut1_2")] <- "InstExp"
colnames(df7)[which(names(df7) == "attribut2_2")] <- "ExtExp"
colnames(df7)[which(names(df7) == "attribut3_2")] <- "Reason"
colnames(df7)[which(names(df7) == "attribut4_2")] <- "Migr"
colnames(df7)[which(names(df7) == "attribut5_2")] <- "Env"
colnames(df7)[which(names(df7) == "C2_rating")] <- "Rating"
colnames(df7)
df7$CJ_Choice <- ifelse(df7$Candidate_Num == 2 & df7$CJ_Choice == 2, 1, 0)
df7$CJ_Choice

Conjoint <- rbind(df6, df7)
colnames(Conjoint)


# Create variable for movement party voters
table(Conjoint$DK19)
table(Conjoint$DE21)
table(Conjoint$HU18)
table(Conjoint$IT18)
table(Conjoint$RO20)
table(Conjoint$UK19)
table(Conjoint$UK19_ni) 


Conjoint$DK19
Conjoint$DE21
Conjoint$HU18
Conjoint$IT18
Conjoint$RO20
Conjoint$UK19
Conjoint$UK19_ni

Conjoint$CJ_InstExp <- NA
Conjoint$CJ_InstExp <- ifelse(Conjoint$InstExp == 1, "No institutional experience",
                              ifelse(Conjoint$InstExp == 2, "12 years in politics but never in government",
                                     ifelse(Conjoint$InstExp == 3, "12 years in politics and part in government", NA)))

Conjoint$movpartvoter <- ifelse(Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | 
                                  Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | 
                                  Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                  Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                  Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) |
                                  Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni), 
                                "Movement party voter", "Traditional party voter")
Conjoint$movpartvoter
Conjoint$movpartvoter <- as.factor(Conjoint$movpartvoter)

Conjoint$movpartypast <- ifelse(Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | 
                                  Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | 
                                  Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                  Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                  Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) |
                                  Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni), 1, 0)
Conjoint$movpartypast


Conjoint$GreenLeftpast <- ifelse(Conjoint$DK19 == 1 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 4 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 9 & !is.na(Conjoint$DK19) | 
                                   Conjoint$DK19 == 15 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 1 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 3 & !is.na(Conjoint$DE21) | 
                                   Conjoint$DE21 == 6 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 3 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 4 & !is.na(Conjoint$HU18) | 
                                   Conjoint$HU18 == 5 & !is.na(Conjoint$HU18) | Conjoint$IT18 == 5 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 7 & !is.na(Conjoint$IT18) | 
                                   Conjoint$RO20 == 1 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 7 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 8 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 2 & !is.na(Conjoint$UK19) |  
                                   Conjoint$UK19 == 4 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 5 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 7 & !is.na(Conjoint$UK19) |
                                   Conjoint$UK19_ni == 2 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19_ni == 3 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$GreenLeftpast)

Conjoint$Rightpast <- ifelse(Conjoint$DK19 == 3 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 6 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 7 & !is.na(Conjoint$DK19) | 
                               Conjoint$DK19 == 17 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 19 & !is.na(Conjoint$DK19) | Conjoint$DE21 == 2 & !is.na(Conjoint$DE21) | 
                               Conjoint$DE21 == 4 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 1 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 2 & !is.na(Conjoint$HU18) | 
                               Conjoint$IT18 == 2 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 3 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 4 & !is.na(Conjoint$IT18) | 
                               Conjoint$RO20 == 2 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 4 & !is.na(Conjoint$RO20) | 
                               Conjoint$RO20 == 6 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 1 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 6 & !is.na(Conjoint$UK19) | 
                               Conjoint$UK19_ni == 1 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19_ni == 1 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$Rightpast)


Conjoint$Centereclecticpast <- ifelse(Conjoint$DK19 == 2 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 5 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 8 & !is.na(Conjoint$DK19) | 
                                        Conjoint$DE21 == 5 & !is.na(Conjoint$DE21) | Conjoint$HU18 == 6 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 7 & !is.na(Conjoint$HU18) | 
                                        Conjoint$IT18 == 1 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 6 & !is.na(Conjoint$IT18) | Conjoint$RO20 == 3 & !is.na(Conjoint$RO20) | 
                                        Conjoint$RO20 == 9 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 3 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 5 & !is.na(Conjoint$UK19_ni), 1, 0)
table(Conjoint$Centereclecticpast)

Conjoint$Eclecticpast <- ifelse(Conjoint$IT18 == 1 & !is.na(Conjoint$IT18), 1, 0)
table(Conjoint$Eclecticpast)


Conjoint$Otherabstainpast <- ifelse(Conjoint$DK19 == 10 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 18 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 11 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 12 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 13 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 14 & !is.na(Conjoint$DK19) | Conjoint$DK19 == 98 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DK19 == 99 & !is.na(Conjoint$DK19) | 
                                      Conjoint$DE21 == 8 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 9 & !is.na(Conjoint$DE21) | 
                                      Conjoint$DE21 == 7 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 10 & !is.na(Conjoint$DE21) | 
                                      Conjoint$DE21 == 98 & !is.na(Conjoint$DE21) | Conjoint$DE21 == 99 & !is.na(Conjoint$DE21) | 
                                      Conjoint$HU18 == 996 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 997 & !is.na(Conjoint$HU18) | 
                                      Conjoint$HU18 == 998 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 999 & !is.na(Conjoint$HU18) | 
                                      Conjoint$HU18 == 998 & !is.na(Conjoint$HU18) | Conjoint$HU18 == 999 & !is.na(Conjoint$HU18) | 
                                      Conjoint$IT18 == 99 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 98 & !is.na(Conjoint$IT18) |
                                      Conjoint$RO20 == 10 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 10 & !is.na(Conjoint$RO20) |                                      
                                      Conjoint$IT18 == 998 & !is.na(Conjoint$IT18) | Conjoint$IT18 == 999 & !is.na(Conjoint$IT18) | 
                                      Conjoint$RO20 == 98 & !is.na(Conjoint$RO20) | Conjoint$RO20 == 998 & !is.na(Conjoint$RO20) | 
                                      Conjoint$RO20 == 999 & !is.na(Conjoint$RO20) | Conjoint$UK19 == 98 & !is.na(Conjoint$UK19) |  
                                      Conjoint$UK19 == 99 & !is.na(Conjoint$UK19) |  Conjoint$UK19 == 998 & !is.na(Conjoint$UK19) |  
                                      Conjoint$UK19_ni == 98 & !is.na(Conjoint$UK19_ni) | Conjoint$UK19 == 99 & !is.na(Conjoint$UK19) | 
                                      Conjoint$UK19 == 998 & !is.na(Conjoint$UK19) | Conjoint$UK19 == 999 & !is.na(Conjoint$UK19) | 
                                      Conjoint$UK19_ni == 998 & !is.na(Conjoint$UK19) | Conjoint$UK19_ni == 999 & !is.na(Conjoint$UK19), 1, 0)
table(Conjoint$Otherabstainpast)



Conjoint$greenmovpartpast <- 0
Conjoint$greenmovpartpast[Conjoint$movpartypast == 1 & Conjoint$GreenLeftpast == 1] <- 1
table(Conjoint$greenmovpartpast)

Conjoint$lefttradpast <- 0
Conjoint$lefttradpast[Conjoint$movpartypast == 0 & Conjoint$GreenLeftpast == 1] <- 1
table(Conjoint$lefttradpast)

Conjoint$rightmovpartpast <- 0
Conjoint$rightmovpartpast[Conjoint$movpartypast == 1 & Conjoint$Rightpast == 1] <- 1
table(Conjoint$rightmovpartpast)

Conjoint$righttradpast <- 0
Conjoint$righttradpast[Conjoint$movpartypast == 0 & Conjoint$Rightpast == 1] <- 1
table(Conjoint$righttradpast)

Conjoint$Centereclecticmovpartpast <- 0
Conjoint$Centereclecticmovpartpast[(Conjoint$movpartypast == 1 & Conjoint$Centereclecticpast == 1) | 
                                     (Conjoint$movpartypast == 1 & Conjoint$Eclecticpast == 1)] <- 1
table(Conjoint$Centereclecticmovpartpast)

Conjoint$Centereclectictradpast <- 0
Conjoint$Centereclectictradpast[(Conjoint$movpartypast == 0 & Conjoint$Centereclecticpast == 1) |
                                  (Conjoint$movpartypast == 0 & Conjoint$Eclecticpast == 1)] <- 1
table(Conjoint$Centereclectictradpast)

Conjoint$Partyvotepast <- ifelse(Conjoint$greenmovpartpast == 1 & !is.na(Conjoint$greenmovpartpast), "Green/left libertarian movement party",
                                 ifelse(Conjoint$lefttradpast == 1 & !is.na(Conjoint$lefttradpast), "Left conventional party",
                                        ifelse(Conjoint$rightmovpartpast == 1 & !is.na(Conjoint$rightmovpartpast), "Radical right movement party",
                                               ifelse(Conjoint$righttradpast == 1 & !is.na(Conjoint$righttradpast), "Right-wing conventional party",
                                                      ifelse(Conjoint$Centereclectictradpast == 1 & !is.na(Conjoint$Centereclectictradpast), "Centrist conventional party",
                                                             ifelse(Conjoint$Centereclecticmovpartpast == 1 & !is.na(Conjoint$Centereclecticmovpartpast), "Centrist & eclectic movement party", "Abstention & Other parties"))))))

table(Conjoint$Partyvotepast)
Conjoint$Partyvotepast <- as.factor(Conjoint$Partyvotepast)

Conjoint$Partytypepast <- ifelse(Conjoint$movpartypast == 1, "Movement party", "Traditional party")
Conjoint$Partytypepast
Conjoint$Partytypepast <- as.factor(Conjoint$Partytypepast)

CJleft <- subset(Conjoint, Conjoint$GreenLeftpast == 1)
CJright <- subset(Conjoint, Conjoint$Rightpast == 1)
CJcentecc <- subset(Conjoint, Conjoint$Centereclecticpast == 1)
CJabs <- subset(Conjoint, Conjoint$Otherabstainpast == 1)

CJmovpart <- subset(Conjoint, Conjoint$movpartypast == 1)
CJmovpart$partid <- ifelse(CJmovpart$GreenLeftpast == 1 & !is.na(CJmovpart$GreenLeftpast == 1), "Green/left",
                           ifelse(CJmovpart$Rightpast == 1 & !is.na(CJmovpart$Rightpast == 1), "Radical Right",
                                  ifelse(CJmovpart$Centereclecticpast == 1 & !is.na(CJmovpart$Centereclecticpast == 1), "Center/Eclectic", 
                                         "Other/Abstain")))
table(CJmovpart$partid)
CJmovpart$partid
CJmovpart$partid [is.na(CJmovpart$partid)] <- "Other/Abstain"
table(CJmovpart$partid)
CJmovpart$partid <- as.factor(CJmovpart$partid)

CJtradpart <- subset(Conjoint, Conjoint$movpartypast == 0)
CJtradpart$partid <- ifelse(CJtradpart$GreenLeftpast == 1 & !is.na(CJtradpart$GreenLeftpast == 1), "Left-wing",
                            ifelse(CJtradpart$Rightpast == 1 & !is.na(CJtradpart$Rightpast == 1), "Right-wing",
                                   ifelse(CJtradpart$Centereclecticpast == 1 & !is.na(CJtradpart$Centereclectictradpast == 1), "Center/Eclectic", "Other/Abstentionist")))
table(CJtradpart$partid)
CJtradpart$partid <- as.factor(CJtradpart$partid)



# Turn attributes into factors for Cregg package

Conjoint$CJ_InstExp <- NA
Conjoint$CJ_InstExp <- ifelse(Conjoint$InstExp == 1, "No institutional experience",
                              ifelse(Conjoint$InstExp == 2, "12 years in politics but never in government",
                                     ifelse(Conjoint$InstExp == 3, "12 years in politics and part in government", NA)))
Conjoint$CJ_InstExp <- as.factor(Conjoint$CJ_InstExp)

Conjoint$CJ_ExtExp <- NA
Conjoint$CJ_ExtExp <- ifelse(Conjoint$ExtExp == 1, "Protest experience",
                             ifelse(Conjoint$ExtExp == 2, "No extra-institutional experience",
                                    ifelse(Conjoint$ExtExp == 3, "Volunteering experience", NA)))
Conjoint$CJ_ExtExp <- as.factor(Conjoint$CJ_ExtExp)

Conjoint$CJ_Reason <- NA
Conjoint$CJ_Reason <- ifelse(Conjoint$Reason == 1, "Anti-elitist",
                             ifelse(Conjoint$Reason == 2, "Neutral",
                                    ifelse(Conjoint$Reason == 3, "Mainstream", NA)))
Conjoint$CJ_Reason <- as.factor(Conjoint$CJ_Reason)

Conjoint$CJ_Migr <- NA
Conjoint$CJ_Migr <- ifelse(Conjoint$Migr == 1, "Open borders to most migrants",
                           ifelse(Conjoint$Migr == 2, "Close borders to most migrants",
                                  ifelse(Conjoint$Migr == 3, "Maintain current migration policies", NA)))
Conjoint$CJ_Migr <- as.factor(Conjoint$CJ_Migr)

Conjoint$CJ_Env <- NA
Conjoint$CJ_Env <- ifelse(Conjoint$Env == 1, "Make climate change a priority",
                          ifelse(Conjoint$Env == 2, "Reverse climate change policies",
                                 ifelse(Conjoint$Env == 3, "Maintain current climate change policies", NA)))
Conjoint$CJ_Env <- as.factor(Conjoint$CJ_Env)
Conjoint$CJ_Env




#### Analysis of Marginal Means

# Movement party vs traditional party - All data

MM_Choice_movtrad_all <- cj(Conjoint, CJ_Choice ~ CJ_InstExp + CJ_ExtExp + CJ_Reason + CJ_Migr + CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Partytypepast)


plot(MM_Choice_movtrad_all, group = "Partytypepast", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)") + 
  scale_colour_manual(name = "Partytypepast",
                      labels = c("Movement party", "Conventional party"),
                      values = c("tomato2", "skyblue3")) +
  ggplot2::facet_wrap(~feature, ncol = 1L,
                      scales = "free_y", strip.position = "top") +
  theme(strip.text.x = element_blank()) +
  theme(text = element_text(size = 15))




MM_Choice_movtrad_all

write.excel(MM_Choice_movtrad_all)



# By party per attribute - All data

Conjoint$Vote <- Conjoint$Partyvotepast


MM_Choice_byparty_instexp <- cj(Conjoint, CJ_Choice ~ CJ_InstExp, 
                                id = ~ID, estimate = "mm", by = ~Vote)

plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", 
     legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_instexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_instexp

write.excel(MM_Choice_byparty_instexp)



MM_Choice_byparty_extexp <- cj(Conjoint, CJ_Choice ~ CJ_ExtExp, 
                               id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_extexp, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_extexp

write.excel(MM_Choice_byparty_extexp)



MM_Choice_byparty_populism <- cj(Conjoint, CJ_Choice ~ CJ_Reason, 
                                 id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")

plot(MM_Choice_byparty_populism, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party", 
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_populism

write.excel(MM_Choice_byparty_populism)


MM_Choice_byparty_migr <- cj(Conjoint, CJ_Choice ~ CJ_Migr, 
                             id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_migr, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))


MM_Choice_byparty_migr

write.excel(MM_Choice_byparty_migr)



MM_Choice_byparty_env <- cj(Conjoint, CJ_Choice ~ CJ_Env, 
                            id = ~ID, estimate = "mm", by = ~Vote)
plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", legend_title = "Past vote", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)")


plot(MM_Choice_byparty_env, group = "Vote", feature_headers = F, legend_pos = "bottom", vline = 0.5, xlab= "Probability of selecting a candidate (Marginal Means)", size = 2) +
  scale_colour_manual(name = "Vote",
                      labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                 "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                 "Right-wing conventional party"),
                      values = c("black", "tomato2", "skyblue3", "tomato2", "skyblue3", "tomato2", "skyblue3")) +   
  scale_shape_manual(name = "Vote",
                     labels = c("Abstention & other parties", "Centrist & eclectic movement party", "Centrist conventional party",  
                                "Green/left libertarian movement party", "Left conventional party", "Radical right movement party",
                                "Right-wing conventional party"),
                     values = c(1, 8, 8, 3, 3, 4, 4)) +
  aes(shape = Vote) +
  theme(text = element_text(size = 15), legend.box.margin = margin(t = 0, r = 230, b = 10, l = 0)) +
  guides(col = guide_legend(ncol = 3))  


MM_Choice_byparty_env

write.excel(MM_Choice_byparty_env)






# Your existing script code goes here

# Set the file path
file_path <- "C:/Users/fgsan/OneDrive - Universitatea Babeş-Bolyai/Work/Papers/Studying the drivers of support for movement parties/PoP/session_info.txt"

# Create the directory if it doesn't exist
dir.create(dirname(file_path), showWarnings = FALSE, recursive = TRUE)

# Capture session information
session_info <- capture.output(sessionInfo())

# Write session information to a file
writeLines(session_info, file_path)

# Confirm the file has been created
cat("Session information has been saved to", file_path)
